package objetosGraficos;

import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

/**
 * Un almacenamiento de sprites
 * <p>
 * [singleton]
 * <p>
 * @author Gonzalo Arr�
 */
public class SpriteStore {
	
	// Atributos de clase
	
	private static SpriteStore single = new SpriteStore();
	private HashMap<String,ImageIcon> sprites = new HashMap<String,ImageIcon>(); 
	
	// Constructor
	
	private SpriteStore () {}
	
	// Métodos
	
	public static SpriteStore get() {
		return single;
	}

	
	public ImageIcon getImage(String ref) {
		ImageIcon toReturn = sprites.get(ref);

		if (toReturn == null){
			toReturn = new ImageIcon(this.getClass().getClassLoader().getResource("recursos/" + ref + ".gif"));
			sprites.put(ref,toReturn);
		}

		return toReturn;
	}
	
	
}